<?php

header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL ^ E_NOTICE);
date_default_timezone_set('Asia/Yekaterinburg');
setlocale(LC_ALL, 'ru_RU');

set_include_path('.'.PATH_SEPARATOR . './library'
  //.PATH_SEPARATOR.'./application/models/'
  //.PATH_SEPARATOR.'./application/cms/models/'
  .PATH_SEPARATOR.get_include_path()
  );

include 'Zend/Loader.php';
Zend_Loader::registerAutoload();

//Zend_Session::start();

$context = new Wh_Ioc_Context('./application/applicationContext.xml');

$obj = $context->get('first');
print '<br>+++++++++ result +++++++++++++<br/>';
Zend_Debug::dump($obj);
print_r($obj->getData());

$obj = $context->get('second');
Zend_Debug::dump($obj);
print_r($obj->getData());

//$context = new Wh_Context('./application/applicationContext.xml');
/*
$frontendOptions = array(
 'lifetime' => 57600,
 'automatic_serialization' => true
);
$backendOptions = array(
    'cache_dir' => './cache/'
);
$tableCache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($tableCache);

$config = new Zend_Config_Ini('./application/config.ini');
Zend_Registry::set('config', $config);
// подключение к базе данных
$db = Zend_Db::factory($config->general->db->adapter, $config->general->db->config->toArray());
$db->query('set names utf8');
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
//Zend_Debug::dump($config->general->db->config->toArray());
// Объект аутентификации
$auth = Zend_Auth::getInstance();

// Создаем настройки прав доступа к модулям, контроллерам и действиям
$acl = new MyAcl($auth); 


$fc = Zend_Controller_Front::getInstance();
$fc->throwExceptions(true);

//укажнем пути к контроллерам модулей по умолчанию, cms 
$fc->setControllerDirectory(array (
  'default'=>'./application/controllers'
  ,'cms'=>'./application/cms/controllers'
 ));
 
//зарегистрируем плагины

$fc->registerPlugin(new MyPluginAuth($auth, $acl));//аутентификация
//$fc->registerPlugin(new NavigationRowPlugin());//строка навигации
//$fc->registerPlugin(new Zend_Controller_Plugin_ErrorHandler());

// старт приложения
$route = new Zend_Controller_Router_Route(
    'portfolio/:rewrite_name', 
    array(
    	'module'     => 'default',
        'controller' => 'port', 
        'action'     => 'index'
    )
);

$fc->getRouter()->addRoute('portfolio', $route);
$route = new Zend_Controller_Router_Route(
    'portfolio/', 
    array(
       	'module'     => 'default',
        'controller' => 'port', 
        'action'     => 'index'
    )
);

$fc->getRouter()->addRoute('portfolio2', $route);

Zend_Layout::startMvc(array('layoutPath'=>'./application/layouts'));
$fc->dispatch();
*/